<template>
  <el-row>
    <el-col :span="6">
      <div style="padding: 20px;height: 500px;overflow-y: auto;">
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="摄像头列表">
            <el-select v-model="form.region" placeholder="请选择摄像头" @change="handleChange">
              <el-option
                v-for="item in list"
                :key="item.id"
                :label="item.label"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-form>
        <el-table
          :data="tableData"
          border
          style="width: 100%"
        >
          <el-table-column
            prop="name"
            label="监控名称"
          />
        </el-table>
      </div>
    </el-col>
    <el-col :span="18">
      <el-row :gutter="20">
        <el-col v-for="item in tableData" :key="item.id" :span="12">
          <el-card class="box-card" style="margin-top:20px;">
            <div>
              {{ item.name }}
            </div>
          </el-card>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
import { getAreaList, getAreaListById } from '@/api/system/areaManage'
export default {
  name: 'VideoSurveillance',
  data() {
    return {
      form: {},
      tableData: [],
      label: null,
      list: []
    }
  },
  created() {
    getAreaList().then(res => {
      console.log(res)
      this.list = res.content.map(element => {
        element.label = element.areaName
        return element
      })
    })
  },
  methods: {
    handleChange(data) {
      getAreaListById(data).then(res => {
        this.tableData = res.content[0].monitorList ? res.content[0].monitorList : []
      })
    }
  }
}
</script>

<style scoped>

</style>
